from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding
from llama_index.core.graph_stores import SimplePropertyGraphStore

embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

text="""金秋十月，中华人民共和国迎来76周年华诞。每逢国庆，无论身处何地，爱国主义情愫都会引发中华儿女心中的共鸣。
爱国，是人世间最深层、最持久的情感，是每一个中国人的心之所系、情之所归。"""

store = SimplePropertyGraphStore()


from llama_index.core.graph_stores.types import EntityNode, ChunkNode, Relation

entity1 = EntityNode(label="PERSON", name="Logan", properties={"age": 28})
entity2 = EntityNode(label="ORGANIZATION", name="LlamaIndex")

# Create a relation
relation = Relation(
    label="WORKS_FOR",
    source_id=entity1.id,
    target_id=entity2.id,
    properties={"since": 2023},
)

store.upsert_nodes([entity1, entity2])
store.upsert_relations([relation])

store.persist('./storage/SimplePropertyGraphStore.json')
